package com.dog.basics.admin.controller.mtkj;


import com.dog.basics.bean.dto.admin.mtkj.ConfigAddDto;
import com.dog.basics.bean.dto.admin.mtkj.ConfigEditDto;
import com.dog.basics.bean.vo.admin.mtkj.ConfigVo;
import com.dog.basics.common.annotation.SysLog;
import com.dog.basics.common.util.R;
import com.dog.basics.service.mtkj.IMtDeviceConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;

/**
 * <p>
 * 设备管理配置信息 前端控制器
 * </p>
 *
 * @author wph
 * @since 2020-09-29
 */
@RestController
@RequestMapping("/pc/device/config")
@Api(value = "设备管理配置信息模块", tags = "设备管理配置信息模块")
@AllArgsConstructor
public class MtDeviceConfigController {
    private final IMtDeviceConfigService mtDeviceConfigService;

    /**
     * @Description: 设备管理配置信息列表
     * @Param: ConfigFromDto
     * @return: IPage<ConfigVo>
     * @Author: wph
     * @Date:
     */

    @ApiOperation(value = "设备管理配置信息列表", notes = "pc:mtDeviceConfig:page")
    @GetMapping("/page")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceConfig:page')")
    public R<ConfigVo> page() {
        return R.ok(mtDeviceConfigService.getPageList());
    }

    /**
     * @Description: 增加设备管理配置信息
     * @Param: ConfigAddDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("增加设备管理配置信息")
    @ApiOperation(value = "增加设备管理配置信息", notes = "pc:mtDeviceConfig:save")
    @PostMapping("/save")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceConfig:save')")
    @ApiIgnore
    public R<Boolean> save(@Valid @RequestBody ConfigAddDto obj) {
        return R.ok(mtDeviceConfigService.saveObj(obj));
    }

    /**
     * @Description: 删除设备管理配置信息
     * @Param: ids
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("删除设备管理配置信息")
    @ApiOperation(value = "删除设备管理配置信息", notes = "pc:mtDeviceConfig:delete")
    @ApiImplicitParam(value = "设备管理配置信息Id", name = "id", dataType = "Long", required = true)
    @DeleteMapping("/delete/{id}")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceConfig:delete')")
    @ApiIgnore
    public R<Boolean> delete(@PathVariable("id") Long id) {
        return R.ok(mtDeviceConfigService.deleteObj(id));
    }

    /**
     * @Description: 修改设备管理配置信息
     * @Param: ConfigEditDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("修改设备管理配置信息")
    @ApiOperation(value = "修改设备管理配置信息", notes = "pc:mtDeviceConfig:edit")
    @PutMapping("/edit")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceConfig:edit')")
    public R<Boolean> edit(@Valid @RequestBody ConfigEditDto obj) {
        return R.ok(mtDeviceConfigService.editObj(obj));
    }
}
